using System;
using System.Collections.Generic;
using System.Text;

namespace RapidHDL.Fabric
{
    public class RegisterBlock : Block 
    {

        int iWidth;
        bool bRisingEdge;

        public RegisterBlock(string psName, int piWidth, bool pbRisingEdge)
            : base(psName,"REG")
        {
            iWidth = piWidth;
            bRisingEdge = pbRisingEdge;
            this.CreateInput("IN", piWidth);
            this.CreateOutput("OUT", piWidth);
            this.CreateControlInput("LATCH");
        }

        internal override void GenerateStructure()
        {
            ResetReg oRegister = new ResetReg(ParentComponent, "reg_" + this.sName, Clock, iWidth, bRisingEdge, true, false);
            //RegisterComponent oRegister = new RegisterComponent(ParentComponent, "reg_" + this.sName, Clock, iWidth, bRisingEdge, true);
            Inputs["IN"].LinkNodeVector(oRegister.InputNodes);
            Outputs["OUT"].LinkNodeVector(oRegister.OutputNodes);
            ControlInputs["LATCH"].LinkNodeVector(oRegister.EnableNodes);
            oRegister.ResetIn.Join(Reset);
            oRegister.ResetTo.Join(0);
            //Inputs["IN"].JoinDefault(Outputs["OUT"]);
        }
 

    }
}
